﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace calendar {

    //工作日类型, 周日 -- 周六, DayType 0 为例外..
    class WeekDay {

        private String m_name;
        private int m_dayType;
        private int m_dayWorking;
        private DateRange m_timePeriod;
        private ArrayList m_workingTimes;


        public WeekDay(int dayType, int dayWorking) {
            m_dayType = dayType;
            m_dayWorking = dayWorking;
            m_workingTimes = new ArrayList();
            switch (dayType) {
                case 0:
                    m_name = "Exception";
                    break;
                case 1:
                    m_name = "Sunday";
                    break;
                case 2:
                    m_name = "Monday";
                    break;
                case 3:
                    m_name = "Tuesday";
                    break;
                case 4:
                    m_name = "Wednesday";
                    break;
                case 5:
                    m_name = "Thursday";
                    break;
                case 6:
                    m_name = "Friday";
                    break;
                case 7:
                    m_name = "Saturday";
                    break;
                default:
                    break;


            }
        }

        public String Name {
            get {
                return m_name;
            }
            set {
                m_name = value;
            }
        }

        public int DayType {
            get {
                return m_dayType;
            }
            set {
                m_dayType = value;
            }
        }

        public int DayWorking {
            get {
                return m_dayWorking;
            }
            set {
                m_dayWorking = value;
            }
        }

        public DateRange TimePeriod {
            get {
                return m_timePeriod;
            }
            set {
                m_timePeriod = value;
            }
        }

        public ArrayList WorkingTimes {
            get {
                return m_workingTimes;
            }
            set {
                m_workingTimes = value;
            }
        }

        public ArrayList AddWorkingTime(DateRange dateRange) {
            dateRange.Start = new DateTime(dateRange.Start.TimeOfDay.Ticks);
            dateRange.End = new DateTime(dateRange.End.TimeOfDay.Ticks);
            if (m_workingTimes.Contains(dateRange) == false) {
                m_workingTimes.Add(dateRange);
            }
            return m_workingTimes;
        }

        public ArrayList RemoveWorkingTime(DateRange dateRange) {
            m_workingTimes.Remove(dateRange);
            return m_workingTimes;
        }

        public override string ToString() {
            String result = "[Name = " + m_name + ", DayWorking = " + m_dayWorking + "]";
            return result;
        }
    }


}
